<?php
namespace app\common\utils;
use GuzzleHttp\Client;

class SmsUtils{
    /**
     * 发送短息
     * @param $mobile
     * @param $code
     * @return bool
     */
    public static function send($mobile,$code){
        $client = new Client();
        $url = "http://api.1cloudsp.com/api/v2/single_send";
        try{
            $response = $client->post($url,['form_params'=>[
                'accesskey' => 'KbAZBTwLU1Qzv16a',
                'secret' => 'OtbLZ0ZQo1I5bb3lrV3DCBttOHPrUoSd',
                'sign' => '18324',
                'templateId' => '30506',
                'mobile' => $mobile,
                'content' => $code,
            ]]);
            $result = $response->getBody()->getContents();
            $result = json_decode($result, 1);
            if($result['code'] == 0){
                return true;
            }
            return false;
        }catch (\Exception $e){
            return false;
        }
    }
}

